home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / SAT / HeartQuest sample ƒ / sBonus.p < prev    next >
Encoding:
Text File  |  1993-09-19  |  1.8 KB  |  78 lines  |  [TEXT/PJMM]

  1. {===============================================}
  2. {================= Bonus sprite unit ================}
  3. {===============================================}
  4.  
  5. { Example file for Ingemars Sprite Animation Toolkit. }
  6. { © Ingemar Ragnemalm 1992 }
  7. { See doc files for legal terms for using this code. }
  8.  
  9. unit sBonus;
  10.  
  11. { Sprite unit. A sprite unit should include the following routines:}
  12. { Init-procedure, that initializes private bitmaps}
  13. { Setup-procedure, that sets variables other than the standard ones set by MakeSprite }
  14. { Handle-procedure, to be called once per iteration until the sprite dies }
  15. { Hittask-procedure (optional), for advanced collission handling. }
  16.  
  17. interface
  18.  
  19.     uses
  20.         SAT, sPoints, scores, SoundConst, GameGlobals;
  21.  
  22.     procedure InitBonus;
  23.     procedure SetupBonus (mp: SpritePtr);
  24.     procedure HandleBonus (me: SpritePtr);
  25.  
  26. implementation
  27.  
  28.     var
  29.         BonusFace: array[1..3] of FacePtr;
  30.  
  31.     procedure InitBonus;
  32.         var
  33.             ii: integer;
  34.             h: handle;
  35.     begin
  36.         for ii := 1 to 3 do
  37.             begin
  38.                 BonusFace[ii] := GetFace(127 + ii);
  39.             end;
  40.     end;
  41.  
  42.     procedure SetupBonus (mp: SpritePtr);
  43.         var
  44.             i: integer;
  45.     begin
  46.         i := rand(3) + 1;
  47.         mp^.face := BonusFace[i];
  48. {mp^.mask := Bonusmask[i];}
  49.  
  50.         if mp^.position.h < 300 then
  51.             mp^.speed.h := 5
  52.         else
  53.             mp^.speed.h := -5;
  54.         SetRect(mp^.hotRect, -13 + 16, -28 + 32, 13 + 16, 0 + 32);
  55.     end;
  56.  
  57.     procedure HandleBonus (me: SpritePtr);
  58.         var
  59.             mp: Spriteptr;
  60.     begin
  61.         if me^.kind <> -4 then
  62.             begin
  63.                 me^.task := nil; { Caught by the player! }
  64.                 addscore(50);
  65.                 mp := NewSprite(0, me^.position.h, me^.position.v, @HandlePoints, @SetupPoints, nil);
  66.                 SATSoundPlay(jaSndH, 5, true);
  67.             end;
  68.  
  69.         me^.mode := me^.mode + 1;
  70.  
  71.         me^.position.h := me^.position.h + me^.speed.h;
  72.         if me^.position.h > offSizeH then
  73.             me^.task := nil;
  74.         if me^.position.h < -32 then
  75.             me^.task := nil;
  76.     end;
  77.  
  78. end.